<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class OpenCity extends Model
{
    public function City()
    {
        return $this->belongsTo('App\Models\CityList', 'key', 'key');
    }

    public static function getCityList()
    {
        $array = OpenCity::join('city_lists', 'open_cities.key', '=', 'city_lists.key')
            ->selectRaw("city_lists.`key` ,city_lists.`name`")
            ->pluck('name', 'key')
            ->toArray();
        return $array;
    }
}
